﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using bdxyit.com.RecruitmentAppSys.BLL;
using bdxyit.com.RecruitmentAppSys.Models;

namespace bdxyit.com.RecruitmentAppSys.Controllers
{
    public class CompanyInfoController : Controller
    {
        //
        // GET: /CompanyInfo/

        public ActionResult Index()
        {
            return View();
        }
        //
        // GET: /BasicInfo/
        //基本信息页面初始化数据
        public ActionResult Details(string FCompanyId)
        {
            List<CompanyInfo> companys = null;// FamilyInfoBLL.GetFamilyInfoByUserId(userId);
            ViewBag.relationships = SystemInfoBLL.GetSystemInfoByCode("CompanyType");
            return View(companys);
        }
        
        [HttpPost]
        public ActionResult Create(CompanyInfo companyInfo, FormCollection collection)
        {
            try
            {
                string[] formValue = collection["SysID"].Split(new char[] { ',' });
                companyInfo.CompanyID = formValue[0];
                companyInfo.CompanyName = formValue[1];
                companyInfo.CompanyType = formValue[2];
                companyInfo.CompanyType = formValue[2];
                companyInfo.CompanyType = formValue[2];
                companyInfo.CompanyType = formValue[2];

                if (ModelState.IsValid)
                {
                    
                }
                return RedirectToAction("Create", "FamilyInfo", new
                {
                    
                });
            }
            catch
            {
                return RedirectToAction("Index");
            }
        }

        public ActionResult Delete(string companyID)
        {
            try
            {
                //bool flag = FamilyInfoBLL.RemoveFamilyInfoByUserId(userID);
                return RedirectToAction("Details", "FamilyInfo", new
                {
                    ID = companyID
                });
            }
            catch
            {
                return RedirectToAction("Index");
            }
        }


        public ActionResult Edit(string userId, string fid)
        {

            FamilyInfo fi = FamilyInfoBLL.GetFamilyInfoByUserIdAndFid(userId, fid);
            return View(fi);
        }

        //
        // POST: 
        [HttpPost]
        public ActionResult Edit(CompanyInfo comInfo, FormCollection form)
        {
            try
            {
                comInfo.CompanyType = form["SysID"].ToString();
                //bool flag =// FamilyInfoBLL.CreateFamilyInfoList(comInfo);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
